package clientGUI.userPanels;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.JLabel;
import javax.swing.JButton;

import javax.swing.JTextField;

import clientGUI.Controllers.Controller;
import clientGUI.userPanels.Controllers.EvaluatorPanelController;
import clientserver.Client;
import javax.swing.JComboBox;
import javax.swing.JTextPane;

import college.Request;

public class EvaluatorPanel extends UPanel implements ActionListener {
	private EvaluatorPanelController contoller;
	private JTextPane requestPane;
	private JComboBox filesCB;
	private JButton btnMainMenu;
	private JButton btnWriteReport;
	private int rid;
	

	/**
	 * Create the panel.
	 */
	public EvaluatorPanel(int id, Client cl)
	{
		super();
		client=cl;
		rid=id;
		setLayout(null);
		
		 contoller = new EvaluatorPanelController(id,cl);
		
	
		
		requestPane = new JTextPane();
		requestPane.setBounds(24, 93, 396, 174);
		requestPane.setText(contoller.getRequestInfo());
		add(requestPane);
		
		filesCB = new JComboBox(contoller.getAttachedFiles().toArray());
		filesCB.setBounds(35, 41, 161, 22);
		add(filesCB);
		
		JButton btnOpen = new JButton("Open");
		btnOpen.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0)
			{
				String fname =(String) filesCB.getSelectedItem();
				
				try {
					contoller.openFileInWindows(fname);
				}
				
				catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
					
				
			}
		});
		btnOpen.setBounds(220, 41, 91, 23);
		add(btnOpen);
		
		btnMainMenu = new JButton("Main Menu");
		btnMainMenu.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				myframe.SetMainUserPanel();
			}
		});
		btnMainMenu.setBounds(351, 11, 89, 23);
		add(btnMainMenu);
		
		btnWriteReport = new JButton("Write Report");
		btnWriteReport.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			EvaluatorReportPanel reppan= new EvaluatorReportPanel(rid, client);
			
			myframe.SetPanel(reppan);
			}
		});
		btnWriteReport.setBounds(321, 59, 119, 23);
		add(btnWriteReport);
		
	
	}
	
	

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}
}
